//导入axios
import axios from 'axios'
import { Loading } from 'element-ui';

const request = axios.create({
  baseURL: 'http://121.199.6.108',
  timeout: 10000
})

let loadingInstance = null

//配置axios的拦截器
request.interceptors.request.use((config) => {
  loadingInstance = Loading.service({ fullscreen: true });
  const token = localStorage.getItem('token')
  if (token) {
    config.headers.Authorization = token;
  }
  return config
})

request.interceptors.response.use((response) => {
  loadingInstance.close()
  return response
})

export default request
